package com.chaoyue.auth.ucenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chaoyue.auth.beans.dto.AuthParamsDto;
import com.chaoyue.auth.beans.dto.CyUserExt;

import com.chaoyue.auth.beans.po.CyUser;
import com.chaoyue.auth.ucenter.mapper.CyUserMapper;
import com.chaoyue.auth.ucenter.service.AuthService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author whr
 * @version 1.0
 * @description: TODO
 * @date 2023/5/30 9:06
 */
@SuppressWarnings({"all"})
@Service("wx_authservice")
public class WxAuthServiceImpl implements AuthService {
    @Autowired
    CyUserMapper xcUserMapper;

    @Override
    public CyUserExt execute(AuthParamsDto authParamsDto) {
        String username = authParamsDto.getUsername();
        CyUser user = xcUserMapper.selectOne(new LambdaQueryWrapper<CyUser>().eq(CyUser::getUsername, username));
        if (user == null) {
            //返回空表示用户不存在
            throw new RuntimeException("账号不存在");
        }
        CyUserExt xcUserExt = new CyUserExt();
        BeanUtils.copyProperties(user, xcUserExt);
        return xcUserExt;

    }
}
